import request from '@/utils/request'

export function getVmList(params) {
  return request({
    url: '/api/vm-service/vm/search',
    params
  })
}

export function getPolicyList(params) {
  return request({
    url: '/api/vm-service/policy',
    params
  })
}

export function useApplyPolicy(data) {
  return request({
    method: 'put',
    url: '/api/vm-service/vm/applyPolicy',
    data
  })
}

export function getNodeList() {
  return request({
    url: '/api/vm-service/node/search',
    params: {
      pageIndex: 1,
      pageSize: 10000
    }
  })
}

export function getVmTypeList() {
  return request({
    url: '/api/vm-service/vmType/search/',
    params: {
      pageIndex: 1,
      pageSize: 10000
    }
  })
}

export function addDevice(data) {
  return request({
    method: 'post',
    url: '/api/vm-service/vm',
    data
  })
}

export function getVmPolicy(id) {
  return request({
    url: `/api/vm-service/policy/vmPolicy/${id}`
  })
}

export function cancelPolicy(data) {
  return request({
    method: 'put',
    url: `/api/vm-service/vm/cancelPolicy/${data.innerCode}/${data.policyId}`,
    data
  })
}

export function putDeviceNode(data) {
  return request({
    method: 'put',
    url: `/api/vm-service/vm/${data.id}/${data.nodeId}`
  })
}

export function getVmType(id) {
  return request({
    url: `/api/vm-service/vmType/${id}`
  })
}

export function getChannelList(id) {
  return request({
    url: `/api/vm-service/channel/channelList/${id}`
  })
}
